package jgl.vajra.driver.part.vehicle.activity;

import androidx.recyclerview.widget.LinearLayoutManager;

import java.util.ArrayList;
import java.util.List;

import jgl.vajra.driver.R;
import jgl.vajra.driver.databinding.ActivityCouponAvailableBinding;
import jgl.vajra.driver.dialogFragment.UseRulesDialogFragment;
import jgl.vajra.driver.part.vehicle.contract.CouponAvailableContract;
import jgl.vajra.driver.part.vehicle.viewModel.CouponAvailableViewModel;
import jgl.vajra.driver.widget.databindingadapter.BaseBindingItemPresenter;
import jgl.vajra.driver.widget.databindingadapter.SingleTypeBindingAdapter;
import jgl.vajra.driver.widget.mvvm.factory.CreateViewModel;
import jgl.vajra.driver.widget.mvvm.view.BaseMVVMActivity;

@CreateViewModel(CouponAvailableViewModel.class)
public class CouponAvailableActivity extends BaseMVVMActivity<CouponAvailableViewModel, ActivityCouponAvailableBinding> implements CouponAvailableContract.View, BaseBindingItemPresenter {

    private SingleTypeBindingAdapter adapter;
    private UseRulesDialogFragment useRulesDialogFragment;

    @Override
    public int getLayoutId() {
        return R.layout.activity_coupon_available;
    }

    @Override
    public void initView() {
        super.initView();

        List<String> list=new ArrayList<>();
        list.add("");
        list.add("");
        list.add("");

        // 不可嵌套滑动
        mBinding.recyclerView.setNestedScrollingEnabled(false);
        // 取消head 的 recycleView的焦点
        mBinding.recyclerView.setFocusableInTouchMode(false);
        //设置布局管理器
        mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(this));
        adapter = new SingleTypeBindingAdapter(this, list, R.layout.item_coupon_available);
        mBinding.recyclerView.setAdapter(adapter);
        adapter.setItemPresenter(this);

    }

    //使用规则
    @Override
    public void onUseRules() {
        if (useRulesDialogFragment == null)
            useRulesDialogFragment = new UseRulesDialogFragment();
        useRulesDialogFragment.show(getSupportFragmentManager());
    }

    @Override
    public void onItemClick(int position, Object itemData) {

    }
}
